package edu.auctionmart

import org.joda.time.*
import edu.auctionmart.User
import edu.auctionmart.Item
import edu.auctionmart.Bid;
import grails.test.mixin.*
import org.junit.*

/**
 * See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
 */
@TestFor(Bid)
class BidTests {

    void testValidation() {
       
		User seller = new User(username: "Russell", password: "Testinga4b", email: "russell@maine.edu")
		User buyer = new User(username: "Brian", password: "abc123", email: "brian@maine.edu")
		Item item = new Item(name: "Movie", description: "Some movie", category: ItemCategory.Electronics, quantity: 1)
		
		DateTime startTime = new DateTime(2012, 2, 12, 0, 0, 0)
		DateTime endTime = new DateTime(2012, 2, 15, 0, 0, 0)
				
		Auction auction = new Auction(auctionTitle: "Title", startBid: 0.01, seller: seller, item: item, startTime: startTime, endTime: endTime)
		
		DateTime date = new DateTime()
		Bid bid = new Bid(auction: auction, userAccount: buyer, amount: 5.00, time: date)
		bid.validate()
		assert(bid.hasErrors() == false)
    }
}
